Skip to content

Conversation

@dosier
Copy link

@dosier dosier commented Sep 13, 2025

Using the openai "type":"response.output_item.done" to only support streaming of completed tool calls.

… package and update imports across modules. Add coroutines dependency to `prompt-model`.
# Conflicts:
#	prompt/prompt-executor/prompt-executor-clients/prompt-executor-anthropic-client/src/commonMain/kotlin/ai/koog/prompt/executor/clients/anthropic/AnthropicLLMClient.kt
#	prompt/prompt-executor/prompt-executor-clients/prompt-executor-google-client/src/commonMain/kotlin/ai/koog/prompt/executor/clients/google/GoogleLLMClient.kt
#	prompt/prompt-executor/prompt-executor-clients/prompt-executor-openai-client/src/commonMain/kotlin/ai/koog/prompt/executor/clients/openai/OpenAILLMClient.kt
#	prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/streaming/StreamFrameExt.kt
…put_item.done` type from official OpenAI API
@dosier dosier changed the base branch from develop to streaming-tools September 13, 2025 21:27
Copy link
Collaborator

@rubencagnie-toast rubencagnie-toast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes on the OpenAILLMClient didn't work as not all tool call chunks were emitted.

I just pushed a StreamingAgentWithTools.kt in the examples folder to my branch. Maybe you can try it out yourself to validate the changes

@dosier
Copy link
Author

dosier commented Sep 15, 2025

How is the current design u think @rubencagnie-toast , I am not sure if my assumptions are correct, but the tests pass, and I tried it with ur openAI example and it works.

Copy link
Collaborator

@rubencagnie-toast rubencagnie-toast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like this new approach! Just added some small questions

streamFrameFlow {
val builder = StreamFrameFlowBuilder(this)
block(builder)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a builder. tryEmitPendingToolCall() just to be safe (in case emitEnd wasn't called properly)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this too yea, but then I was also thinking if emitEnd wasn't called then that probably means the stream was cancelled prematurely for some reason and the pending tool call is most likely incomplete in that case.

But it all depends on whether apis guarantee to always send a finishReason at some point, which I think it does from reading the docs. But not 100% sure.

Copy link
Collaborator

@rubencagnie-toast rubencagnie-toast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Feel free to merge!

@dosier
Copy link
Author

dosier commented Sep 15, 2025

Great work! Feel free to merge!

Aight, checks are failing so I cannot merge it in here. Have yet to update some docs and probably style issues.
Ehm, u can either force merge it into urs first and then I merge urs into my original streaming-tools branch and continue work from there. Or I just directly merge this into my streaming-tools branch. Only reason I am asking is in case u have left-over changes it might cause some weird conflicts if u try to later merge streaming-tools back into urs haha.

EDIT: okay I merged the changes in dosier/streaming-tools

@rubencagnie
Copy link
Owner

Great work! Feel free to merge!

Aight, checks are failing so I cannot merge it in here. Have yet to update some docs and probably style issues. Ehm, u can either force merge it into urs first and then I merge urs into my original streaming-tools branch and continue work from there. Or I just directly merge this into my streaming-tools branch. Only reason I am asking is in case u have left-over changes it might cause some weird conflicts if u try to later merge streaming-tools back into urs haha.

EDIT: okay I merged the changes in dosier/streaming-tools

Sound perfect. I'll close this PR and we can work from yours as the base! Thanks for the collaboration, I think this is a great change to the framework!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants